﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:ViewModel="clr-namespace:GBlason.ViewModel"
                    xmlns:Aggregate="clr-namespace:GBlason.Control.Aggregate"
                    xmlns:Converter="clr-namespace:GBlason.Common.Converter"
                    xmlns:Control="clr-namespace:GBlason.ViewModel.Control"
                    xmlns:General="clr-namespace:GBlason.ViewModel.General">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="..\Themes\Brushes.xaml"/>
    </ResourceDictionary.MergedDictionaries>



    <!-- TabControl / TabItem -->

    <Style  TargetType="{x:Type TabControl}">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabControl}">
                    <Grid KeyboardNavigation.TabNavigation="Local"
                          Background="Transparent">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <!--Background="{StaticResource ResourceKey=GlobalBackgroundBrush}"
                                BorderBrush="{StaticResource ResourceKey=LightColorBackgroundBrush}"-->
                        <Border Grid.Row="0"
                                Panel.ZIndex="1"
                                Background="{StaticResource ResourceKey=GlobalBackgroundBrush}"
                                BorderBrush="{StaticResource ResourceKey=LightColorBackgroundBrush}"
                                BorderThickness="0,0,0,1"
                                Margin="0,0,-1,-1">
                            <TabPanel x:Name="HeaderPanel"
                                      IsItemsHost="True"
                                      KeyboardNavigation.TabIndex="1" />
                        </Border>
                        <Border x:Name="ExternBorder"
                                    Grid.Row="1"
                                    BorderThickness="1"
                                    BorderBrush="{StaticResource ResourceKey=HardDarkColorBorderBrush}"
                                    CornerRadius="0"
                                    Background="{StaticResource ResourceKey=HardDarkColorBackgroundBrush}"
                                    KeyboardNavigation.TabNavigation="Local"
                                    KeyboardNavigation.DirectionalNavigation="Contained"
                                    KeyboardNavigation.TabIndex="2">
                            <Border x:Name="ExternLight"
                                    Grid.Row="1"
                                    BorderThickness="1"
                                    BorderBrush="{StaticResource ResourceKey=LightColorBorderBrush}"
                                    Margin="0">
                                <Border x:Name="InnerLight"
                                    Grid.Row="1"
                                    BorderThickness="1"
                                    BorderBrush="{StaticResource ResourceKey=LightColorBorderBrush}"
                                    Margin="2">
                                    <Border x:Name="InternBorder"
                                        Grid.Row="1"
                                        BorderThickness="1"
                                        Margin="0"
                                        BorderBrush="{StaticResource ResourceKey=HardDarkColorBorderBrush}"
                                            
                                        CornerRadius="0">
                                        <DockPanel Background="{Binding Source={x:Static General:GlobalApplicationViewModel.GetApplicationViewModel}, Path=BlasonViewerBackgroundColor}">
                                            <Border x:Name="DropShadowBorder" DockPanel.Dock="Top"
                                                    Background="{StaticResource ResourceKey=UserControlHeaderDropingShadow}"
                                                    Height="4"/>
                                            <ContentPresenter x:Name="PART_SelectedContentHost"
                                                          ContentSource="SelectedContent"
                                                          VerticalAlignment="Stretch"
                                                          HorizontalAlignment="Stretch"
                                                          Margin="0"/>
                                        </DockPanel>

                                    </Border>
                                </Border>
                            </Border>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="ExternBorder" Property="Opacity" Value=".55"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type TabItem}">
        <Style.Resources>
            <Converter:StringToImageConverter x:Key="StringToImage"/>
        </Style.Resources>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <Grid x:Name="Root">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" MaxWidth="160"/>
                            <!--<ColumnDefinition Width="12"/>-->
                        </Grid.ColumnDefinitions>
                        <Border x:Name="ExternBorder"
                                Grid.Column="0"
                                    Margin="0,4,1,0"
                                    BorderThickness="1,1,1,0"
                                    CornerRadius="3,3,0,0"
                                    BorderBrush="{StaticResource ResourceKey=HardDarkColorBorderBrush}"
                                    Background="{StaticResource ResourceKey=UserControlInvertedHeaderBackgroundBrush}">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height=".5*"/>
                                    <RowDefinition Height=".5*"/>
                                </Grid.RowDefinitions>
                                <Border x:Name="Glossy" Grid.Row="0" Background="{StaticResource ResourceKey=GlossyBrush}" Opacity="0"
                                            CornerRadius="3,3,0,0"/>
                                <Border x:Name="Glow" Grid.Row="1" Background="{StaticResource ResourceKey=GlowBrush}" Opacity="0"/>
                                <Border x:Name="Shadow" Grid.Row="1" Background="{StaticResource ResourceKey=InnerShadowUp}" Opacity="1"
                                            Margin="1,0,1,0"/>
                                <Border x:Name="AntiBorderUp" Grid.Row="1" BorderThickness="0,0,0,1" Opacity="0"
                                            VerticalAlignment="Bottom" Height="1"
                                            BorderBrush="{StaticResource ResourceKey=HardDarkColorBackgroundBrush}"
                                            Margin="1,0,1,-1"/>
                                <Border x:Name="AntiBorderDown" Grid.Row="1" BorderThickness="0,0,0,1" Opacity="0"
                                            VerticalAlignment="Bottom" Height="1"
                                            BorderBrush="{StaticResource ResourceKey=HardDarkColorBackgroundBrush}"
                                            Margin="1,0,1,-2"/>
                                <Border x:Name="InnerBorder"
                                        Margin="0,0,0,0"
                                        CornerRadius="3,3,0,0"
                                        BorderThickness="1,1,1,0"
                                        BorderBrush="{StaticResource ResourceKey=LightColorBorderBrush}"
                                            Grid.RowSpan="2">
                                    <DockPanel VerticalAlignment="Center"
                                               HorizontalAlignment="Center">
                                        <Image DockPanel.Dock="Left" x:Name="fileIcon"
                                               VerticalAlignment="Center" HorizontalAlignment="Center"
                                               Margin="4,2,2,2" Width="16" Height="16"
                                               Source="{Binding Path=IconName, Converter={StaticResource ResourceKey=StringToImage}}"/>
                                        <ContentPresenter x:Name="ContentSite"
                                                          VerticalAlignment="Center"
                                                          HorizontalAlignment="Center"
                                                          ContentSource="Header"
                                                          Margin="0,4,0,4"
                                                          RecognizesAccessKey="True"
                                                          DockPanel.Dock="Left"/>
                                        <Image x:Name="IsSavedImage"
                                               DockPanel.Dock="Left"
                                               Visibility="{Binding Path=IsUnsaved}"
                                               Source="pack://application:,,,/Pictures/Icons16/bullet_disk.png"
                                               Height="16" Width="16"
                                               Margin="2"/>
                                        <Button x:Name="CloseButton"
                                                DockPanel.Dock="Right"
                                                Margin="2"
                                                Width="16"
                                                Height="16"
                                                VerticalAlignment="Center"
                                                HorizontalAlignment="Center"
                                                Style="{StaticResource MenuRecentFileButtonStyle}">
                                            <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">Ｘ</TextBlock>
                                        </Button>
                                    </DockPanel>
                                </Border>

                            </Grid>

                        </Border>

                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Panel.ZIndex" Value="100" />
                            <Setter TargetName="AntiBorderUp" Property="Opacity" Value="1"/>
                            <Setter TargetName="ExternBorder" Property="Background" Value="{StaticResource ResourceKey=HardUserControlHeaderBackgroundBrush}"/>
                            <Setter TargetName="AntiBorderDown" Property="Opacity" Value="1"/>
                            <Setter TargetName="InnerBorder" Property="Margin" Value="0,0,0,-1"/>
                            <Setter TargetName="ExternBorder" Property="Margin" Value="0,0,1,0"/>
                            <Setter TargetName="Shadow" Property="Opacity" Value="0"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="false"/>
                                <Condition Property="IsMouseOver" Value="True"/>
                            </MultiTrigger.Conditions>
                            <MultiTrigger.Setters>
                                <Setter TargetName="Glossy" Property="Opacity" Value="1"/>
                                <Setter TargetName="Glow" Property="Opacity" Value="1"/>
                                <Setter TargetName="ExternBorder" Property="Background" Value="{StaticResource ResourceKey=YellowBackgroundBrush}"/>
                                <Setter TargetName="ExternBorder" Property="BorderBrush" Value="{StaticResource ResourceKey=DarkYellowBorderBrush}"/>
                                <Setter TargetName="Shadow" Property="Opacity" Value="0"/>
                            </MultiTrigger.Setters>
                        </MultiTrigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="ExternBorder" Property="Opacity" Value=".45"/>
                            <Setter TargetName="Shadow" Property="Opacity" Value="0"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Tab Control Items Template -->
    <DataTemplate x:Key="CoAViewerTemplate" DataType="{x:Type General:GbsFileViewModel}">
        <Aggregate:CoatOfArmsViewer VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="0" CoatOfArms="{Binding Path=RootCoatOfArm}"/>
    </DataTemplate>

    <DataTemplate x:Key="ResourceEditorItemTemplate" DataType="{x:Type Control:ResourceEditorViewModel}">
        <Aggregate:ResourcePage VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="0"/>
    </DataTemplate>

    <DataTemplate x:Key="StartingPageTemplate" DataType="{x:Type Control:StartingPageViewModel}">
        <Aggregate:StartingPage VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="0"/>
    </DataTemplate>

</ResourceDictionary>